package com.ygqh.baby.model;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 多买多折 多阶梯model
 *
 * @author admin
 */
public class BmdismLadderModel {
    private Long id;

    private Date startTime;

    private Date endTime;

    private List<String> productIdList;

    private List<BmdismLadderModel.BmdismLadder> ladderList;

    public List<BmdismLadder> getLadderList() {
        return ladderList;
    }

    public void setLadderList(List<BmdismLadder> ladderList) {
        this.ladderList = ladderList;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public List<String> getProductIdList() {
        return productIdList;
    }

    public void setProductIdList(List<String> productIdList) {
        this.productIdList = productIdList;
    }

    public Boolean isValid() {
        long millis = System.currentTimeMillis();
        return millis - startTime.getTime() >= 0 && millis - endTime.getTime() < 0;

    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        BmdismLadderModel that = (BmdismLadderModel) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(startTime, that.startTime) &&
                Objects.equals(endTime, that.endTime) &&
                Objects.equals(productIdList, that.productIdList);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, productIdList);
    }

    /**
     * 多买多折阶梯
     */
    public class BmdismLadder {
        private Long bmdismId;

        private int buyCount;

        private BigDecimal disCount;

        public BmdismLadder() {
        }

        public BmdismLadder(Long bmdismId, int buyCount, BigDecimal disCount) {
            this.bmdismId = bmdismId;
            this.buyCount = buyCount;
            this.disCount = disCount;
        }

        public Long getBmdismId() {
            return bmdismId;
        }

        public void setBmdismId(Long bmdismId) {
            this.bmdismId = bmdismId;
        }

        public int getBuyCount() {
            return buyCount;
        }

        public void setBuyCount(int buyCount) {
            this.buyCount = buyCount;
        }

        public BigDecimal getDisCount() {
            return disCount;
        }

        public void setDisCount(BigDecimal disCount) {
            this.disCount = disCount;
        }
    }


}
